// const rp = require('request-promise');
// const _ = require('lodash');

var appkey = 'kj7swf8oksp72';
var secret = 'FKy2i66ctjKv4X';

var RongSDK = require('rongcloud-sdk')({
  appkey: appkey,
  secret: secret
});

module.exports = class extends think.Service {
  async createUser(id, name, avatar) {
    var User = RongSDK.User;
    var user = {
      id: 'yk-' + id,
      name: name,
      portrait: avatar || 'https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2146034403,1504718527&fm=26&gp=0.jpg'
    };
    const token = await User.register(user);
    return token;
  }
  async createRoom(id, name) {
    var Chatroom = RongSDK.Chatroom;
    var chatroom = {
      id: id,
      name: name
    };
    const room = await Chatroom.create(chatroom);
    return room;
  }
};
